<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
<c:if test="${sessionScope.loginMember == null }">
	<jsp:forward page="loginPage.sds"></jsp:forward>
</c:if>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>StepUp-Rank</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<style type="text/css">
	.highlight{
		font-weight: bolder;
	}
</style>
</head>

<body>

	<div id="wrapper">

		<nav class="navbar-default navbar-static-side" role="navigation">
			<div class="sidebar-collapse">
				<ul class="nav" id="side-menu">
				
				<!-- 사용자 정보 -->
					<li class="nav-header">
						<div class="dropdown profile-element">
							<span>
								<c:if test="${sessionScope.loginMember.mimage == null}">
									<img alt="image" class="img-circle"
									src="imgUpload/anonymous.jpg" width="160px"/>
								</c:if>
								<c:if test="${sessionScope.loginMember.mimage != null}">
									<img alt="image" class="img-circle"
									src="imgUpload/${sessionScope.loginMember.mimage}" width="160px"/>
								</c:if>
							</span> <a data-toggle="dropdown" class="dropdown-toggle" href="#">
								<span class="clear"> <span class="block m-t-xs"> <strong
										class="font-bold">${sessionScope.loginMember.mname}</strong>
								</span> <span class="text-muted text-xs block">
									${sessionScope.loginMember.mposition}
								<b class="caret"></b>
								</span>
							</span>
							</a>
							<ul class="dropdown-menu animated fadeInRight m-t-xs">
								<li><a href="stepup_profile.sds">Profile</a></li>
								<li class="divider"></li>
								<li><a href="logout.sds">Logout</a></li>
							</ul>
						</div>
					</li>
					<!-- 메뉴 리스트 -->
					<li><a href="index.sds"><i
							class="fa fa-bar-chart-o"></i> <span class="nav-label">Statistics</span></a></li>
					<li class="active"><a href="stepup_rank.sds"><i class="fa fa-flask"></i>
							<span class="nav-label">Ranking</span></a></li>
					<li><a href="stepup_badge.sds"><i class="fa fa-desktop"></i>
							<span class="nav-label">Badge</span></a></li>
					<li><a href="stepup_mission.sds"><i
							class="fa fa-envelope"></i> <span class="nav-label">Mission</span></a></li>
					<li><a href="stepup_temp.sds"><i class="fa fa-sitemap"></i>
							<span class="nav-label">Thermometer</span></a></li>
					<li><a href="stepup_donation.sds"><i class="fa fa-globe"></i>
							<span class="nav-label">Donation</span></a></li>
				</ul>
			</div>
		</nav>

		<div id="page-wrapper" class="gray-bg">
		
		<!-- 상단 메뉴 바 -->
			<div class="row border-bottom">
				<nav class="navbar navbar-static-top" role="navigation"
					style="margin-bottom: 0">
					<div class="navbar-header">
						<a class="navbar-minimalize minimalize-styl-2 btn btn-primary "
							href="#"><i class="fa fa-bars"></i> </a>
						<form role="search" class="navbar-form-custom" method="post"
							action="search_results.html">
							<div class="form-group">
								<input type="text" placeholder="Search for something..."
									class="form-control" name="top-search" id="top-search">
							</div>
						</form>
					</div>

					<!-- 상단 메뉴 - 검색, 로그아웃 포함 -->
					<ul class="nav navbar-top-links navbar-right">
						
						<!-- 상단 : 로그인, 로그아웃 버튼 -->
						<c:if test="${sessionScope.loginMember != null}">
							<li><a href="stepup_profile.sds"><i class="fa fa-sign-out"></i>
								Profile
							</a></li>
							<li><a href="logout.sds"> <i class="fa fa-sign-out"></i>
								Logout
							</a></li>
						</c:if>
					</ul>
				</nav>
			</div>

			<!-- 메인 페이지: 제 목 -->
			<div class="row wrapper border-bottom white-bg page-heading">
				<div class="col-lg-10">
					<h2>직원/부서별 랭킹 리스트</h2>
					<ol class="breadcrumb">
						<li>Home</li>
						<li>랭킹리스트</li>
						<li class="active"><strong>직원/부서별</strong></li>
					</ol>
				</div>
				<div style="padding: 20px 30px 0px 0px">
					<img alt="image" class="img-responsive" src="img/logo.jpg"
					 style="Height: 80px; width: 80px;" align="right"  >
				</div>
				<div class="col-lg-2"></div>
			</div>

			<!-- 메뉴 - ranking -->
			<div class="wrapper wrapper-content animated fadeInRight">
				<div class="row">
					<div class="col-lg-6">
						<div class="ibox float-e-margins">
							<div class="ibox-title">
								<h5>직원별 랭킹 리스트</h5>
							</div>
							<div class="ibox-content">
								<div class="col-sm-7 m-b-xs">
									<label class="btn btn-sm btn-white">
										<input type="radio" id="day1" name="option1" value="day" style="display: none;">Day
									</label>
									<label class="btn btn-sm btn-white active highlight">
										<input type="radio" id="month1" name="option1" value="month" style="display: none;">Month
									</label>
									<label class="btn btn-sm btn-white">
										<input type="radio" id="year1" name="option1" value="year" style="display: none;">Year
									</label>
								</div>
								<table class="table table-striped">
									<thead>
										<tr>
											<th>#</th>
											<th>Name</th>
											<th>Position</th>
											<th>Dept Name</th>
											<th>Stairs</th>
										</tr>
									</thead>
									<tbody id="userRank">
									</tbody>
								</table>
							</div>
						</div>
					</div>
					<div class="col-lg-6">
						<div class="ibox float-e-margins">
							<div class="ibox-title">
								<h5>부서별 랭킹 리스트</h5>
							</div>
							<div class="ibox-content">
								<div class="col-sm-7 m-b-xs">
									<label class="btn btn-sm btn-white">
										<input type="radio" id="day2" name="option2" value="day" style="display: none;">Day
									</label>
									<label class="btn btn-sm btn-white active highlight">
										<input type="radio" id="month2" name="option2" value="month" style="display: none;">Month
									</label>
									<label class="btn btn-sm btn-white">
										<input type="radio" id="year2" name="option2" value="year" style="display: none;">Year
									</label>
								</div>
								<table class="table table-hover">
									<thead>
										<tr>
											<th>#</th>
											<th>Dept No.</th>
											<th>Dept Name</th>
											<th>Buliding Num.</th>
											<th>Stairs</th>
										</tr>
									</thead>
									<tbody id="deptRank">
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="footer">
				<div align="right">
						StepUp System. Copyright <strong> &copy; SHINHAN DATA SYSTEM.</strong> All Right Reserved. 2015.
					</div>
			</div>
			</div>

		</div>


	<!-- Mainly scripts -->
	<script src="js/jquery-2.1.1.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script src="js/plugins/slimscroll/jquery.slimscroll.min.js"></script>

	<!-- Peity -->
	<script src="js/plugins/peity/jquery.peity.min.js"></script>

	<!-- Custom and plugin javascript -->
	<script src="js/inspinia.js"></script>
	<script src="js/plugins/pace/pace.min.js"></script>

	<!-- iCheck -->
	<script src="js/plugins/iCheck/icheck.min.js"></script>

	<!-- Peity -->
	<script src="js/demo/peity-demo.js"></script>

	<script>
		function memberRanking(val){
			$.ajax({
				url : "member_month_ranking.sds",
				type : "post",
				data : { "type" : val },
				async : false,
				dataType : "json",
				success : function(data) {
					var i;
					$("#userRank").empty();
					$.each(data, function(index, item){
						i = index+1;
						$("#userRank").append(
								"<tr>" +
									"<td>"+i+"</td>"+
									"<td>"+item.mname+"</td>"+
									"<td>"+item.mposition+"</td>"+
									"<td>"+item.dname+"</td>"+
									"<td class='text-navy'>"+"<i class='fa fa-level-up'>"+"</i>"+" "+ item.stairs+
									"</td>"+
								"</tr>"
						);
					});
				},
				error : function() {
					alert("실패: " + data.status);
				}
			});
		}
		
		function deptRanking(val2){
			$.ajax({
				url : "dept_month_ranking.sds",
				type : "post",
				data : { "type" : val2 },
				async : false,
				dataType : "json",
				success : function(data) {
					var i;
					$("#deptRank").empty();
					$.each(data, function(index, item){
						i = index+1;
						$("#deptRank").append(
								"<tr>"+
								"<td>"+i+"</td>"+
								"<td>"+item.dno+"</td>"+
								"<td>"+item.dname+"</td>"+
								"<td>"+item.bno+"</td>"+
								"<td class='text-navy'>"+"<i class='fa fa-level-up'>"+"</i>"+item.stairs+
								"</td>"+
							"</tr>"
						);
					});
				},
				error : function() {
					alert("실패: " + data.status);
				}
			});
		}
		/* $(":not(this)"). */
		$(document).ready(function() {
			$("#month1").prop("checked", true);
			memberRanking($("#month1").val());
			$("input[name=option1]").on("click", function(){
				var val = $(this).val();
				$(this).parent().parent().children().removeClass("active highlight");
				$(this).parent().addClass("active highlight");
				memberRanking(val);
			});
			
			$("#month2").prop("checked", true);
			deptRanking($("#month2").val());
			$("input[name=option2]").on("click", function(){
				var val = $(this).val();
				$(this).parent().parent().children().removeClass("highlight active");
				$(this).parent().addClass("highlight active");
				deptRanking(val);
			});
			
			$('.i-checks').iCheck({
				checkboxClass : 'icheckbox_square-green',
				radioClass : 'iradio_square-green',
			});
		});
	</script>

</body>

</html>
